<?php
class UserRuleModel extends Model{
    protected $table = 'user_rule';
    public function getById(){
        $rule_id = Request::asget(3,'id',null);
        if($rule_id == null){
            exit;
        }else{
            return $this->where(['rule_id'=>$rule_id])->one();
        }
    }
    public function up($id){
        $names = [
            'rule_name'=>6,
            'rule_title'=>6,
            'rule_type'=>3,
            'rule_condition'=>6,
            'rule_description'=>6,
        ];
        $data = Request::batch(1,$names);
        return $this->where(['rule_id'=>$id])->update($data);
    }
    public function add(){
        $names = [
            'rule_id'=>3,
            'rule_name'=>6,
            'rule_title'=>6,
            'rule_type'=>3,
            'rule_condition'=>6,
            'rule_description'=>6,
        ];
        $data = Request::batch(1,$names);
        return $this->insert($data);
    }
    public function getRulesBySerialize($ids){
        $_ids = unserialize($ids);
        $data = $this->where(['rule_id'=>$_ids])->select();
        return $data;
    }
}